<template>
  <view class="topfix">
	  <view :style="{height:getstateheight()+'px'}"></view>
	  <view class="toptit" :style="{height:gettitileheight()+'px',paddingRight:gettitlepadding()+25+'px'}">
		   <view style="width:50rpx;" class="iconfont icon-fanhui" @click="fanhui"></view>
		   <view class="">我的收藏</view>
		   <view style="width:50rpx;" class=""></view>
	  </view>
  </view>
  <view :style="{height:heightbox}"></view>
  <view class="con">
	     <scroll-view scroll-y="true" @scrolltolower="getdata">
	     	 <view class="item" v-for="i in showdata" :key="i.id" @click="goshowdata(i.hoseid)">
	     				 <ScCard @delelovehise="delelovehise" :data="i"/>
	     	 </view>
			  <uni-load-more :status="current.length<7?'no-more':'loading'"></uni-load-more>
	     </scroll-view>
  </view>
</template>

<script setup>
	import {ref} from 'vue'
	import {onLoad,onHide,onShow} from '@dcloudio/uni-app'
	import ScCard from '@/components/sccard/sccard.vue'
	import {getstateheight,gettitileheight,gettitlepadding} from '@/utils/getinfo.js'
	import userstore from '@/store/userlogin.js'
	const useuserstore=userstore()
	const heightbox=getstateheight()+gettitileheight()+'px'
	const limit=ref(7)
	const orrset=ref(0)
	const showdata=ref([])
	const current=ref([])
	const isgo=ref(0)
	const issend=ref(0)
	const fanhui=()=>{
		uni.navigateBack()
	}
	onLoad(()=>{
		getdata()
	})
	const delelovehise=id=>{
		const index=showdata.value.findIndex(e=>e.id==id)
		showdata.value.splice(index,1)
	}
	const getdata=()=>{
		if(isgo.value)return
		orrset.value++
		if(limit.value * (orrset.value -1)+limit.value>useuserstore.userlove.length-1){
			current.value=useuserstore.userlove.slice(limit.value * (orrset.value -1))
			showdata.value.push(...current.value)
			isgo.value=1
			return
		}
		current.value=useuserstore.userlove.slice(limit.value * (orrset.value -1),limit.value * (orrset.value -1)+limit.value)
		showdata.value.push(...current.value)
	}
	onShow(()=>{
		isgo.value=0
	})
	onHide(()=>{
		if(issend.value)return
		orrset.value=0
		showdata.value=[]
		isgo.value=0
	})
	const goshowdata=id=>{
		 issend.value=1
		 uni.navigateTo({
		 	url:`/pages/showdata/showdata?id=${id}`
		 })
	}
</script>

<style lang="scss" scoped>
	::-webkit-scrollbar{
		display: none;
	}
	.topfix{
		position: fixed;
		top: 0;
		width: 100%;
		background-color: #fff;
		z-index: 99;
		.toptit{
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0  25rpx;
			font-size: 25rpx;
			.iconfont{
			    font-size: 25rpx;
			}
		}
	}
	.con{
		height: calc(100vh -  v-bind(heightbox));
		padding:20rpx;
		scroll-view{
			height: 100%;
			width: 100%;
			.item:first-child{
				margin-top: 5rpx;
			}
			.item{
				 height:16%;
				 width: 98%;
				 margin:0 auto 20rpx auto ;
				 border-radius: 12rpx;
				 overflow: hidden;
				 box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.09);
			}
		}
		
	}
</style>
